﻿using EA.BA;
using EA.Common;
using EA.DTO;
using EAWebAdmin.template;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace EAAdmin
{
    public partial class CreateProductCategory : WebPage
    {
        override        
        protected void Load(object sender, EventArgs e)
        {
            String pCategory=Request.Form["pCategory"];
            if(pCategory!=null)
            {
                if ("".Equals(pCategory))
                {
                    Attributes.Add("err", "Name can not be empty");
                }
                else
                {
                    Boolean stt = false;
                    ProductCategoryTO productCategory = new ProductCategoryTO();
                    productCategory.Name = pCategory;
                    productCategory.CreateDate = DateTime.Now;
                    productCategory.Status = Constant.PRODUCT_CATEGORY_ACTICE;
                    ProductCategoryBA productCategoryBA = new ProductCategoryBA();
                    stt = productCategoryBA.InsertProductCategory(productCategory);
                    if (stt == true)
                    {
                        Attributes.Add("success", "Insert success");
                        return;
                    }
                    else
                    {
                        Attributes.Add("err", "Insert faulty");
                        return;
                    }
                }
            }
        }
    }
}